<?php
error_reporting(E_ALL ^ E_NOTICE);
require '../../config/config.php';
session_start();
$outTradeNo = $_GET['outTradeNo'];
if (!empty($outTradeNo)) {
    $ch = curl_init();
    $str = "" . $outTradeNo; //官方订单查询网关，用于查询订单状态，请勿修改！暂不对外提供服务
    curl_setopt($ch, CURLOPT_URL, $str);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);
    $output = mb_convert_encoding($output, "GBK", "UTF-8");
    $output = substr($output, 25);
    if ($output == "666666") {
        //echo "SUCCESS:支付成功！";
        mysqli_query($con,"UPDATE `order_record` SET `order_state` = '1' WHERE `order_no` = '".$outTradeNo."'");
        $order=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM `order_record` where `order_no`='".$outTradeNo."'"));
        mysqli_query($con,"UPDATE `borrowing_record` SET `state` = '2' WHERE `orid` = '".$order['rid']."'");
    	echo "<script>location='../../borrow.php';</script>";
        //这里请编写认证成功后的操作！echo "<script>alert('支付成功！');location='../order.php?order=".$outTradeNo."';</script>";
    } else {
        echo "支付失败！";
        //这里请编写认证失败的操作！
    }
} else {
    echo "System Erro!";
}
